<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:a="http://richfaces.org/a4j"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:s="http://jboss.com/products/seam/taglib" 
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:rg="http://www.ruijie.com.cn/faces/ui"
	xmlns:c="http://java.sun.com/jstl/core"
	template="/layout/contentLayout.xhtml">
	
	<ui:param name="param_pageTitle" value="#{messages.luyuan_crm_menu_order}" />
	<ui:param name="param_navigationUrl" value="/luyuan/product/navigationProduct.jsf" />
	
	<ui:define name="road">
		<span><h:outputLink value="/luyuan/formula/listFormula.jsf">#{messages.luyuan_crm_formula_order}</h:outputLink></span>
	</ui:define>
	
	<!-- content -->	
	<ui:define name="content">
		<h:form id="formulaForm">
			<rg:areaPanel>
				<rg:areaPanel type="searchPanel" style="margin-top: 10px;">
					<rg:fieldSet column="auto" labelWidth="120px" >
						<rg:inputText id="name" label="配方名称" value="#{formulaAction.criteria.name}" />
						 <rg:selectOne id="productType" label="产品类型" value="#{formulaAction.criteria.productType}" 
								enableEmpty="true" itemsProvider="#{productTypeProvider}" converter="#{productTypeConverter}"/>
					    <rg:field>
							<h:commandButton styleClass="button" value="搜索" />
						</rg:field>
					</rg:fieldSet>
				</rg:areaPanel>
				<rg:titlePanel headerTitle="配方列表" style="margin-top: 10px;" needButton="true" readonly="false">
					<ui:define name="headerActions">
						<h:commandLink action="/luyuan/formula/addFormula.jsf" value="增加"/>
					</ui:define>
					<rg:table tableId="formulaTable" value="#{formulaAction.tableModel}" var="item">
						<rg:column property="name" title="配方名称"  width="100" height="100"/>
						<rg:column property="productType.typeName" title="配方类型"  width="100" height="100"/>
						<rg:column property="price" title="原价"  width="100"/>
						<rg:column property="specialPrice" title="特价"  width="100"/>
						<rg:column title="是否在售" >
							<h:outputLabel value="在售" rendered="#{item.enabled}"/>
							<h:outputLabel value="停止销售" style="color:red" rendered="#{!item.enabled}"/>
						</rg:column>
						<rg:column title="#{messages.luyuan_crm_operator}">
							<ul class="links">
								<li>
									<h:commandLink action="/luyuan/formula/detailFormula.jsf" value="查看">
										<f:param name="formulaId" value="#{item.id}"/>
									</h:commandLink>
								</li>
								<li>
									<h:commandLink action="/luyuan/formula/updateFormula.jsf" value="修改">
										<f:param name="formulaId" value="#{item.id}"/>
									</h:commandLink>
								</li>
								<li>
									<h:commandLink value="停止销售" action="#{formulaAction.disableByFormulaId(item.id)}"
									 	rendered="#{item.enabled}"/>
									<h:commandLink value="重新销售" action="#{formulaAction.enableByFormulaId(item.id)}"
										rendered="#{!item.enabled}"/>
								</li>
								<li>
									<h:commandLink value="#{messages.luyuan_crm_delete}" action="#{formulaAction.deleteByFormulaId(item.id)}"
									onclick="if(!confirm('#{messages.crud_del_warn_confirm}')){return;}" />
								</li>
							</ul>
						</rg:column>
					</rg:table>
				</rg:titlePanel>
			</rg:areaPanel>
		</h:form>
		<a:form>
			<a:jsFunction name="reRenderFormulaTable" reRender="formulaTable"/>
		</a:form>
	</ui:define>
</ui:composition>